import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { Cache } from "../../../cache/Cache";
import { EEquip } from "../../../../../Message/Public/EEquip";
import { ItemConfig } from "../../../resource/ItemConfig";
import { SJewelTarget } from "../../../../../Message/Public/SJewelTarget";
import { ItemData } from "../../../resource/info/ItemData";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { WuXingConfig } from "../../../resource/WuXingConfig";
import { ColorConfig } from "../../../resource/ColorConfig";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
type int = number;
//class PlayerEqStrengthInfo
    
    export  class PlayerEqStrengthInfo
    {
        

        public static getEqStrengthAmount(arg1: int, arg2: string): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=null;
            if (arg2 == GModuleEvent.Mode_Self || arg2 == GModuleEvent.Mode_PreSecondCareer) 
            {
                loc1 = Cache.instance.pack.rolePackCache.getAllItems();
            }
            else 
            {
                loc1 = PlayerEqStrengthInfo.otherEquipments;
            }
            var loc4=0;
            var loc5=0;
            while (loc5 < loc1.length) 
            {
                if ((loc3 = loc1[loc5]) && loc3.itemInfo && !(loc3.itemInfo.item.type == EEquip._EEquipFashion) && !(loc3.itemInfo.item.type == EEquip._EEquipWing) && !(loc3.itemInfo.item.type == EEquip._EEquipFashionWeapon) && !(loc3.itemInfo.item.type == EEquip._EEquipFootPrint) && !(loc3.itemInfo.item.type == EEquip._EEquipBubble) && !(loc3.itemInfo.item.type == EEquip._EEquipSurround) && !(loc3.itemInfo.item.type == EEquip._EEquipWaistBelt) && !(loc3.itemInfo.item.type == EEquip._EEquipElf)) 
                {
                    if ((loc4 = PlayerEqStrengthInfo.getStrengthen(loc3)) >= arg1) 
                    {
                        ++loc2;
                    }
                }
                ++loc5;
            }
            return loc2;
        }

        public static getEqJewelAmount(arg1: int, arg2: string): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=null;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            if (arg2 == GModuleEvent.Mode_Self || arg2 == GModuleEvent.Mode_PreSecondCareer) 
            {
                loc1 = Cache.instance.pack.rolePackCache.getAllItems();
            }
            else 
            {
                loc1 = PlayerEqStrengthInfo.otherEquipments;
            }
            var loc4=0;
            loc6 = 0;
            while (loc6 < loc1.length) 
            {
                if ((loc3 = loc1[loc6]) && loc3.itemExInfo && !(loc3.itemInfo.item.type == EEquip._EEquipFashion) && !(loc3.itemInfo.item.type == EEquip._EEquipWing)) 
                {
                    loc7 = 1;
                    while (loc7 <= 6) 
                    {
                        if ((loc4 = loc3.itemExInfo["hole" + loc7]) > 1) 
                        {
                            if ((loc5 = ItemConfig.instance.getInfoByCode(loc4)) && loc5.item.itemLevel >= arg1) 
                            {
                                loc2 = loc2 + 1;
                            }
                        }
                        ++loc7;
                    }
                }
                ++loc6;
            }
            return loc2;
        }

        public static getEqJewelTarget(arg1: string): SJewelTarget
        {
            if (arg1 == GModuleEvent.Mode_Self || arg1 == GModuleEvent.Mode_PreSecondCareer) 
            {
                return PlayerEqStrengthInfo.myJewelTarget;
            }
            return PlayerEqStrengthInfo.otherJewelTarget;
        }

        public static getStrengthen(arg1: ItemData): int
        {
            var loc1=0;
            if (arg1 == null) 
            {
                return 0;
            }
            var loc2=arg1.itemExInfo;
            if (loc2 && !(loc2.strengthen == 0)) 
            {
                loc1 = loc2.strengthen;
                if (loc2.perfectStrengthen < 100) 
                {
                    --loc1;
                }
            }
            return loc1;
        }

        public static getSpriteTargetToolTip(arg1: string): string
        {
            var loc1=null;
            var loc5=0;
            var loc6=null;
            if (arg1 == GModuleEvent.Mode_Self || arg1 == GModuleEvent.Mode_PreSecondCareer) 
            {
                loc1 = Cache.instance.pack.rolePackCache.getAllItems();
            }
            else 
            {
                loc1 = PlayerEqStrengthInfo.otherEquipments;
            }
            PlayerEqStrengthInfo.updateSpriteTargetItemNum(loc1);
            var loc2=HTMLUtil.addColor(Language.getString(26416), GlobalStyle.color2);
            loc2 = loc2 + "<br><br>";
            var loc3=2;
            var loc4=5;
            while (loc4 >= loc3) 
            {
                if ((loc5 = PlayerEqStrengthInfo._spriteTargetColor[loc4]) == 13) 
                {
                    break;
                }
                --loc4;
            }
            if (loc4 < 2) 
            {
                loc4 = 2;
            }
            loc3 = loc4;
            if (loc5 != 13) 
            {
                loc4 = 2;
            }
            else if ((loc4 = loc3 + 1) > 5) 
            {
                loc4 = 5;
            }
            while (loc3 <= loc4) 
            {
                loc5 = PlayerEqStrengthInfo._spriteTargetColor[loc3];
                loc6 = GameDefConfig.instance.getWuxingTileName(loc3);
                if (loc5 != 13) 
                {
                    loc2 = loc2 + (loc6 + Language.getStringByParam(26413, loc6, loc5));
                    loc2 = loc2 + "<br>";
                    loc2 = loc2 + (Language.getString(26412) + WuXingConfig.instance.getWuxingSpiritTarget(loc3));
                }
                else 
                {
                    loc2 = loc2 + HTMLUtil.addColor(loc6 + Language.getStringByParam(26411, loc6), ColorConfig.instance.getWuxingColor(loc3));
                    loc2 = loc2 + "<br>";
                    loc2 = loc2 + HTMLUtil.addColor(Language.getString(26412) + WuXingConfig.instance.getWuxingSpiritTarget(loc3), ColorConfig.instance.getWuxingColor(loc3));
                }
                loc2 = loc2 + "<br><br>";
                ++loc3;
            }
            PlayerEqStrengthInfo.wxNum = loc5;
            loc2 = loc2 + HTMLUtil.addColor(Language.getString(26414), GlobalStyle.color3);
            return HTMLUtil.addColor(loc2, GlobalStyle.color1);
        }

        /* internal  */static updateSpriteTargetItemNum(arg1: Array<any>): void
        {
            var loc3=null;
            var loc4=0;
            PlayerEqStrengthInfo._spriteTargetColor = [0, 0, 0, 0, 0, 0];
            var loc1=0;
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                if ((loc3 = arg1[loc1]) && loc3.itemInfo && !ItemsUtil.isMount(loc3) && !ItemsUtil.isFashion(loc3)) 
                {
                    var loc5;
                    var loc6;
                    var loc7=((loc5 = PlayerEqStrengthInfo._spriteTargetColor)[loc6 = loc3.wxColor] + 1);
                    loc5[loc6] = loc7;
                    loc4 = 0;
                    while (loc4 < loc3.wxColor) 
                    {
                        loc7 = ((loc5 = PlayerEqStrengthInfo._spriteTargetColor)[loc6 = loc4] + 1);
                        loc5[loc6] = loc7;
                        ++loc4;
                    }
                }
                ++loc1;
            }
            return;
        }

        public static /* var */otherEquipments: Array<any>;

        public static /* var */otherEquipmentsSecondCareer: Array<any>;

        public static /* var */wxNum: int;

        public static /* var */myJewelTarget: SJewelTarget;

        public static /* var */otherJewelTarget: SJewelTarget;

        /* internal */ static /* var */_spriteTargetColor: Array<any>;
    }

            PlayerEqStrengthInfo.otherEquipments = [];
            PlayerEqStrengthInfo.otherEquipmentsSecondCareer = [];
        